<template>
  <div class="container" @click="handleGallaryClick">
    <div class="wrapper">
      <swiper :options="swiperOptions">
        <swiper-slide class="slide" v-for="item of list" :key="item.id">
          <div class="img">
            <img class="swiper-img" :src="item.img"/>
          </div>
        </swiper-slide>
        <div class="swiper-pagination" slot="pagination"></div>
      </swiper>
    </div>
  </div>
</template>

<script>
export default {
  name: 'CommonGallary',
  data () {
    return {
      swiperOptions: {
        pagination: '.swiper-pagination',
        paginationType: 'fraction',
        observeParents: true,
        observer: true
      },
      list: [{
        id: '01',
        img: 'http://img1.qunarzz.com/sight/p0/1409/19/adca619faaab0898245dc4ec482b5722.jpg_r_800x800_6edd8174.jpg'
      },
      {
        id: '02',
        img: 'http://img1.qunarzz.com/sight/p0/1909/4e/4e1afc2e1133ade7a3.img.jpg_r_800x800_d3eb324d.jpg'
      }, {
        id: '03',
        img: 'http://img1.qunarzz.com/sight/p0/1907/ca/ca68bd95bc36bdba3.img.jpg_r_800x800_33169c4b.jpg'
      }]
    }
  },
  methods: {
    handleGallaryClick () {
      this.$emit('close')
    }
  }
}
</script>

<style lang="stylus" scoped>
  .container >>> .swiper-container
    overflow: inherit
  .container >>> .swiper-wrapper
    align-items: center
  .container
    display: flex
    position: fixed
    align-items: center
    flex-direction: column
    justify-content: center
    top: 0
    left: 0
    bottom: 0
    right: 0
    width: 100%
    height: 100%
    z-index: 99
    background: #000
    color: #fff
    .wrapper
      position: relative
      height: 0
      width: 100%
      padding-bottom: 100%
      .swiper-img
        width: 100%
    .swiper-pagination
      bottom: -1rem
</style>
